package cn.icatw.leetcode.editor.cn;

import java.util.Scanner;

/**
 * @author 王顺 762188827@qq.com
 * @apiNote
 * @since 2024/3/28
 */
public class YunzhiTest {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //n个小孩
        int n = in.nextInt();
        //m个苹果
        int m = in.nextInt();
        //小明的编号为k
        int k = in.nextInt();
        System.out.println(maxApplesFork(n, m, k));
    }

    private static int maxApplesFork(int n, int m, int k) {
        //m，苹果数量、n人数、k小明编号
        if (k > n) {
            //小明所在下标大于总人数
            return -1;
        }
        int left = k - 1, right = n - k, used = n;
        int lnum = 0, rnum = 0, i, count = 1;
        //左右边界
        for (i = 1; i <= n && used <= m;) {
            count++;
            used += i;
            if (used >= m) {
                return used > m ? count - 1 : count;
            }
            i += lnum >= left ? 0 : 1;
            i += rnum >= right ? 0 : 1;
            lnum++;
            rnum++;
        }
        return -1;
    }
}
